﻿using System;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;

namespace PAT.Util
{
    public class UtilUI
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objList"></param>
        /// <param name="dataSource"></param>
        /// <param name="dataFieldValue"></param>
        /// <param name="dataFieldText"></param>
        public static void BindListControl(ListControl objList, IList dataSource, String dataFieldValue, String dataFieldText, Boolean includeNullValue)
        {
            objList.DataSource = dataSource;
            objList.DataValueField = dataFieldValue;
            objList.DataTextField = dataFieldText;
            objList.DataBind();
            if (includeNullValue)
                objList.Items.Insert(0, new ListItem(ConfigurationManager.AppSettings["EmptyListItemText"], String.Empty));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="objList"></param>
        public static void AddNullItemListControl(ListControl objList, Boolean clearItems)
        {
            if (clearItems) objList.Items.Clear();
            objList.Items.Insert(0, new ListItem(ConfigurationManager.AppSettings["EmptyListItemText"], String.Empty)); 
        }
    }
}
